﻿#region ExcuteHalconProc.cs
// ============================================================================
// This region will be filled automatically with data if you are working
// for example with Microsoft SourceSafe
//
// Purpose:          
// Specifics: 
// 
// Creation date:    2024/1/3 21:32:37
// Created by:       hao.chen
//
// $Author:        $
// $Date:          $
// $Revision:      $
// $History:       $
// $NoKeywords:    $
// 
// Copyright:      © 2024 YourCompanyName
//                 All Rights Reserved
// ============================================================================
#endregion

using CLVisionHalcon_NC;
using CLVisionTrace;
using NeuroCheck.PlugInLib.API;
using NeuroCheck.PlugInLib.Base;
using NeuroCheck.PlugInLib.ImageProcessing;
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

// TODO: Namespace - Modify the namespace to the project namespace
namespace CLVisionHalconNC620
{
    /// <summary>Implements the check function "ExcuteHalconProc".
    /// </summary>
    /// <remarks>The code for saving and loading the check function instance is in the file "ExcuteHalconProc_Binary.cs".
    /// The code file "ExcuteHalconProc_Enums.cs" contains the necessary enums.
    /// </remarks>
    // TODO: Attributes - Modify the values in all attributes below
    [NcPICanNotBeAppendedHint("The check function mainly implements the calling function of Halcon Procedure")]
    // TODO: CustomVisualization - Include the NcPICustomVisualization attribute and the method GetCustomVisualization 
    //                             if this check function implements a custom visualization.
    /*
    [NcPICustomVisualization(new string[] { "Dummy image" })]
    */
    [NcPIDescription("Excute CheckFunction")]
    [NcPIDetailedDescription("The check function has no input/output interface, and data is stored and read through Tray and Register")]
    [NcPIDisplayName("ExcuteHalconProc")]
    [NcPIHasParameterDialog(true)]
    [NcPIHasParameters(true)]
    [NcPIHasTargetValueDialog(false)]
    [NcPIHasTargetValues(false)]
    [NcPIHelpID(1001)]
    [NcPIParameterDialogIsDependent(false)]
    [NcPIPlugInCheckFunction(true)]
    // TODO: Runtime Data - Modify the input and output runtime data if needed
    [NcPIRuntimeInputData()]



    [NcPIRuntimeOutputData()]
    //  [NcPIRuntimeOutputData(NcPIRuntimeDataTypeConfigInfo.ROICollection, NcPIRuntimeDataTypeConfigInfo.MeasurementCollection, NcPIRuntimeDataTypeConfigInfo.Image)]
    [NcPITargetValueDialogIsDependent(false)]
    [Obfuscation(ApplyToMembers = false)]
    public partial class ExcuteHalconProc : NcPICheckFunctionBase
    {
      
        /// <summary>Constructor.
        /// </summary>
        public ExcuteHalconProc()
            : base()
        {
        }
      
        //public static HalconCallerNC nC_Halcon;
        /// <summary>Creates instances of objects that are necessary within this check function.
        /// </summary>
        /// <returns>True, if the instances were created successfully; otherwise false.</returns>
        public override bool Create()
        {
            m_Parameters = new ExcuteHalconProcParameter();
            return true;
        }

        /// <summary>Calls a class containing the implementation of the execution method for this check function.
        /// </summary>
        /// <param name="exeArgs">The execution arguments containing the runtime (input and output) data.</param>
        /// <param name="isInAutomaticMode">Specifies if this check function is executing in automatic mode.</param>
        /// <returns>The check function execution result as a value of <c>NcPIExecutionResultInfo</c>.</returns>
        public override NcPIExecutionResultInfo Execute(NcPICheckFunctionExecutionArgs exeArgs, bool isInAutomaticMode)
        {
             // Create check function parameters and target values.
             ExcuteHalconProcParameter parameter = (ExcuteHalconProcParameter)m_Parameters;
            // ExcuteHalconProcTargetValue targetValue = (ExcuteHalconProcTargetValue)m_TargetValues;
            //
            // Pass the objects to the class containing the implementation of the execution method for this check function.
            ExcuteHalconProcExecute checkFunction = new ExcuteHalconProcExecute(exeArgs, parameter);
          
            return checkFunction.Execute(null, this, isInAutomaticMode);
        }

        /// <summary>Initializes the members of the check function beside parameters or target values.
        /// </summary>
        /// <param name="isInAutomaticMode">Determines if this check function is initializing within the NeuroCheck automatic mode.</param>
        /// <returns>True on success; otherwise false.</returns>
        public override bool Initialize(bool isInAutomaticMode)
        {
            return true;
        }

        /// <summary>Uninitializes the members of the check function.
        /// </summary>
        public override void Uninitialize()
        {
        }

    

      
      
        // TODO: CustomVisualization - Include this method and the NcPICustomVisualization attribute
        //                             if this check function implements a custom visualization.    
        /*
        /// <summary>Returns a bitmap with custom visualization.
        /// </summary>
        /// <param name="exeArgs">The execution arguments containing the runtime (input and output) data.</param>
        /// <param name="viewIndex">View index the image is requested for.</param>
        /// <returns>Bitmap with custom visualization.</returns>
        public override Bitmap GetCustomVisualization(NcPICheckFunctionExecutionArgs exeArgs, int viewIndex)
        {
            // TODO: CustomVisualization - Example code how to implement custom visualization
            #region --- Example ---

            // This check function creates 1 Image
            // Check the view index the image is requested for
            switch (viewIndex)
            {
                case 0:
                    {
                        // Create a dummy bitmap
                        Bitmap bmp = new Bitmap(200, 200);
                        return bmp;
            
                    } // eof case 0
                default:
                    {
                        throw new NcPIUserException(String.Format("No visualization for view index '{0}'", viewIndex));
            
                    } // eof default
            } // eof switch viewIndex

            #endregion --- Example ---
        }
        */

    

    } // end of class
} // end of namespace